import java.util.Arrays;

class Solution2 {
    public boolean CheckPermutation(String s1, String s2) {
        if (s1.length() != s2.length()) {
            return false;
        }

        // 利用两个数组模拟哈希表
        char[] hash1 = new char[26];
        char[] hash2 = new char[26];

        for (int i = 0; i < s1.length(); i++) {
            char ch = s1.charAt(i);
            hash1[ch - 97]++;
        }
        for (int i = 0; i < s2.length(); i++) {
            char ch = s2.charAt(i);
            hash2[ch - 97]++;
        }
        return Arrays.equals(hash1, hash2);
    }

    public static void main(String[] args) {

    }
}